package com.golte.utils;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

/**
 * @version: 1.0
 * @description: 数据转换工具类
 * @author: chenhuan
 * @date: 2021/6/3
 **/
@Component
public class DataUtils {

    /**
     * @description: [泛型方法]复制对象数据
     * @author: chenhuan
     * @date: 2021/6/3
     * @version V1.0
     **/
    public <T> T convertData(Object source, Class<T> clazz) {
        T t = null;
        try {
            t = clazz.newInstance();
            BeanUtils.copyProperties(source, t);
        } catch (Exception ex) {

        }
        return t;

    }

}
